import { FilterConst } from "../../../component/gconst/FilterConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { Global } from "../../../../com/gengine/global/Global";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { TweenMax } from "../../../../com/greensock/TweenMax";
import { Linear } from "../../../../com/greensock/easing/Linear";
import { MsgManager } from "../../manager/MsgManager";
import { 2 } from "../../../../1/2";
type int = number;
//class RollTipsItem
    
    export  class RollTipsItem /* flash.display.Sprite */
    {
        constructor(arg1: int=320)
        {
            
            this._width = arg1;
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            mouseEnabled = false;
            mouseChildren = false;
            this._bmp = new Object /* flash.display.Bitmap */();
            addChild(this._bmp);
            this._textField = new Object /* flash.text.TextField */();
            this._textField.selectable = false;
            this._textField.width = this._width;
            this._textField.height = 24;
            this._textField.filters = [FilterConst.rollTipsFilter, FilterConst.rollTipsFilter2];
            var loc1=new GTextFormat(FontUtil.songtiName, 14, 12002609, true, null, null, null, null, flash.text.TextFormatAlign.LEFT);
            loc1.letterSpacing = 2;
            this._textField.defaultTextFormat = loc1;
            this._textField.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._textField.multiline = true;
            this._textField.wordWrap = true;
            return;
        }

        public updateData(arg1: string, arg2: Function): void
        {
            this._timeIn = false;
            this._endCall = arg2;
            this._textField.width = Global.stage.stageWidth / 2 - 120;
            this._textField.htmlText = HTMLUtil.addColor(arg1, "#ffffff");
            this._textField.y = 0;
            this._textField.alpha = 1;
            if (this._bmpd) 
            {
                this._bmpd.dispose();
                this._bmpd = null;
            }
            this._bmpd = new Object /* flash.display.BitmapData */(this._textField.textWidth, this._textField.textHeight + 2, true, 0);
            this._bmpd.draw(this._textField);
            this._bmp.bitmapData = this._bmpd;
            this._bmp.y = 0;
            this._bmp.alpha = 0;
            TweenMax.to(this._bmp, 1.5, {"alpha": 2, "y":-100, "ease": Linear.easeInOut(30, 400, 3, 40), "onComplete": this.onInEnd});
            return;
        }

        /* internal  */onInEnd(): void
        {
            if (MsgManager.rollMsgLength > 1) 
            {
                this.onTimeOut();
            }
            else 
            {
                this._timeKey = flash.utils.setTimeout(this.onTimeOut, 1000);
                this._timeIn = true;
            }
            return;
        }

        /* internal  */onTimeOut(): void
        {
            this._timeIn = false;
            TweenMax.to(this._bmp, 0.5, {"alpha": 0, "y":-130, "ease": Linear.easeOut(30, 400, 3, 40), "onComplete": this.onOutEnd});
            return;
        }

        /* internal  */onOutEnd(): void
        {
            if (this._endCall != null) 
            {
                this._endCall.call(this, this);
            }
            return;
        }

        public clearTimeOut(): void
        {
            if (this._timeIn) 
            {
                this._timeIn = false;
                flash.utils.clearTimeout(this._timeKey);
                this.onTimeOut();
            }
            return;
        }

        public dispose(): void
        {
            if (this._bmpd) 
            {
                this._bmpd.dispose();
                this._bmpd = null;
            }
            this._textField.text = "";
            this._bmp.y = 0;
            this._bmp.alpha = 1;
            this._endCall = null;
            return;
        }

        /* internal */ /* var */_bmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpd: Object /* flash.display.BitmapData */;

        /* internal */ /* var */_textField: Object /* flash.text.TextField */;

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_endCall: Function;

        /* internal */ /* var */_timeKey: uint;

        /* internal */ /* var */_timeIn: Boolean;
    }
